﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="view"
    targetNamespace="urn:effun-net-data-view"
    elementFormDefault="qualified"
    xmlns="urn:effun-net-data-view"
    xmlns:mstns="urn:effun-net-data-view"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:complexType name="field">
    <xs:sequence>
      <xs:element name="matches" minOccurs="0" maxOccurs="1">
        <xs:complexType>
          <xs:choice maxOccurs="unbounded">
            <xs:element name="literal" type="literal" minOccurs="0" ></xs:element>
            <xs:element name="condition" type="match" minOccurs="0" ></xs:element>
          </xs:choice>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required"></xs:attribute>
    <xs:attribute name="property" type="xs:string"></xs:attribute>
    <xs:attribute name="displayIndex" type="xs:integer"></xs:attribute>
    <xs:attribute name="hAlign">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="Left"></xs:enumeration>
          <xs:enumeration value="Center"></xs:enumeration>
          <xs:enumeration value="Right"></xs:enumeration>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="vAlign">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="Top"></xs:enumeration>
          <xs:enumeration value="Middle"></xs:enumeration>
          <xs:enumeration value="Bottom"></xs:enumeration>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="aggregate" default="None">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="None"></xs:enumeration>
          <xs:enumeration value="Sum"></xs:enumeration>
          <xs:enumeration value="Min"></xs:enumeration>
          <xs:enumeration value="Max"></xs:enumeration>
          <xs:enumeration value="AverageAll"></xs:enumeration>
          <xs:enumeration value="AverageValues"></xs:enumeration>
          <xs:enumeration value="CountAll"></xs:enumeration>
          <xs:enumeration value="CountValues"></xs:enumeration>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attributeGroup ref="overridables"></xs:attributeGroup>
  </xs:complexType>

  <xs:attributeGroup name="overridables">
    <xs:attribute name="format" type="xs:string"></xs:attribute>
    <xs:attribute name="size" type="xs:integer"></xs:attribute>
    <xs:attribute name="description" type="xs:string"></xs:attribute>
    <xs:attribute name="label" type="xs:string"></xs:attribute>
    <xs:attribute name="nullText" type="xs:string"></xs:attribute>
    <xs:attribute name="hideDefaultValue" type="xs:boolean"></xs:attribute>
  </xs:attributeGroup>

  <xs:complexType name="match" mixed="true">
    <xs:attributeGroup ref="overridables"></xs:attributeGroup>
  </xs:complexType>

  <xs:complexType name="literal">
    <xs:complexContent>
      <xs:extension base="match">
        <xs:attribute name="eval" type="xs:string"></xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="group">
    <xs:choice minOccurs="1" maxOccurs="unbounded">
      <xs:element name="field" type="field" minOccurs="0" maxOccurs="unbounded"></xs:element>
      <xs:element name="group" type="group" minOccurs="0" maxOccurs="unbounded"></xs:element>
    </xs:choice>
    <xs:attribute name="name" type="xs:Name" use="required"></xs:attribute>
  </xs:complexType>
  
  <xs:element name="view">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="modelType" type="xs:string" minOccurs="1" maxOccurs="1"></xs:element>
        <xs:element name="items" >
          <xs:complexType>
            <xs:choice maxOccurs="unbounded">
              <xs:element name="field" type="field" minOccurs="0" maxOccurs="unbounded"></xs:element>
              <xs:element name="group" type="group" minOccurs="0" maxOccurs="unbounded"></xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
